<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2007-2009 Thomas Krause (thomas@berlin-reloaded.de)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->

<xsl:stylesheet
  xmlns:xhtml="http://www.w3.org/1999/xhtml"
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
  exclude-result-prefixes="xhtml xsl xs">

  <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
  
  <xsl:template match="/gidootml">
    <xsl:apply-templates />
  </xsl:template>

  <!-- ignore di for now -->
  <xsl:template match="di" priority="1">
    <xsl:apply-templates />
  </xsl:template>
  
  <!-- ignore sections for now -->
  <xsl:template match="section" priority="1">
    <xsl:apply-templates />
  </xsl:template>
  
  
  <!-- headings, use section as decision helper and default to h1 -->
  <xsl:template match="section/section/section/section/section/h" priority="6">
    <h6>
      <xsl:for-each select="@*"><xsl:attribute name="{name()}"><xsl:value-of 
  select="."/></xsl:attribute>
      </xsl:for-each>
      
      <xsl:apply-templates />
    </h6>
  </xsl:template>
  
  <xsl:template match="section/section/section/section/h" priority="5">
    <h5>
      <xsl:for-each select="@*"><xsl:attribute name="{name()}"><xsl:value-of 
  select="."/></xsl:attribute>
      </xsl:for-each>
      
      <xsl:apply-templates />
    </h5>
  </xsl:template>
  
  <xsl:template match="section/section/section/h" priority="4">
    <h4>
      <xsl:for-each select="@*"><xsl:attribute name="{name()}"><xsl:value-of 
  select="."/></xsl:attribute>
      </xsl:for-each>
      
      <xsl:apply-templates />
    </h4>
  </xsl:template>
  
  <xsl:template match="section/section/h" priority="3">
    <h3>
      <xsl:for-each select="@*"><xsl:attribute name="{name()}"><xsl:value-of 
  select="."/></xsl:attribute>
      </xsl:for-each>
      
      <xsl:apply-templates />
    </h3>
  </xsl:template>
 
  <xsl:template match="section/h" priority="2">
    <h2>
      <xsl:for-each select="@*"><xsl:attribute name="{name()}"><xsl:value-of 
  select="."/></xsl:attribute>
      </xsl:for-each>
      
      <xsl:apply-templates />
    </h2>
  </xsl:template>

  <xsl:template match="h" priority="1">
    <h1>
      <xsl:for-each select="@*"><xsl:attribute name="{name()}"><xsl:value-of 
  select="."/></xsl:attribute>
      </xsl:for-each>
      
      <xsl:apply-templates />
    </h1>
  </xsl:template>
    
  <!-- end headings -->
  
  <!-- blockcode -->
  <xsl:template match="blockcode" priority="1">
    <pre><code>
        <xsl:for-each select="@*"><xsl:attribute name="{name()}"><xsl:value-of 
    select="."/></xsl:attribute>
        </xsl:for-each>

        <xsl:apply-templates />
    </code></pre>
  </xsl:template>

<!-- EXTENDED BEGIN -->

  <!-- youtube embedded -->
  <xsl:template match="youtube" priority="1">
    <object width="425" height="344">
      <param name="allowFullScreen" value="true" />
      <param name="movie">
        <xsl:attribute name="value">
          <xsl:value-of select="concat('http://www.youtube.com/v/',@yid,'&amp;fs=1')" />
        </xsl:attribute>
      </param>      
      <embed type="application/x-shockwave-flash" width="425" height="344" allowfullscreen="true">
        <xsl:attribute name="src">
          <xsl:value-of select="concat('http://www.youtube.com/v/',@yid,'&amp;fs=1')" />
        </xsl:attribute>
      </embed>
    </object>
  </xsl:template>

<!-- EXTENDED END -->  

   <!-- copy all default elements -->
  <xsl:template match="*" priority="-1">
    <xsl:element name="{name()}">
      <xsl:for-each select="@*"><xsl:attribute name="{name()}"><xsl:value-of 
  select="."/></xsl:attribute>
      </xsl:for-each>
      <xsl:apply-templates/>
    </xsl:element>
  </xsl:template>

</xsl:stylesheet>
